#!/usr/bin/env python
# -*- coding:utf-8 -*-

from flask_restful import Resource, reqparse
from flask import jsonify

from service.adminExperimentmanagementService import AdminExperimentmanagementService
from utils import commons
from utils.response_code import RET


class AdminExperimentmanagementOtherResource(Resource):

    @classmethod
    def joint_query(cls):
        parser = reqparse.RequestParser()
        parser.add_argument('experiment_id', location='args', required=False, help='experiment_id参数类型不正确或缺失')
        parser.add_argument('experiment_name', location='args', required=False, help='experiment_name参数类型不正确或缺失')
        parser.add_argument('classroom', location='args', required=False, help='classroom参数类型不正确或缺失')
        parser.add_argument('start_time', location='args', required=False, help='start_time参数类型不正确或缺失')
        parser.add_argument('end_time', location='args', required=False, help='end_time参数类型不正确或缺失')
        parser.add_argument('description', location='args', required=False, help='description参数类型不正确或缺失')
        parser.add_argument('teacher_id', location='args', required=False, help='teacher_id参数类型不正确或缺失')
        parser.add_argument('teacher_name', location='args', required=False, help='teacher_name参数类型不正确或缺失')
        
        parser.add_argument('Page', location='args', required=False, help='Page参数类型不正确或缺失')
        parser.add_argument('Size', location='args', required=False, help='Size参数类型不正确或缺失')

        kwargs = parser.parse_args()
        kwargs = commons.put_remove_none(**kwargs)
        
        res = AdminExperimentmanagementService.joint_query(**kwargs)
        if res['code'] == RET.OK:
            return jsonify(code=res['code'], message=res['message'], data=res['data'], totalCount=res['totalCount'], totalPage=res['totalPage'])
        else:
            return jsonify(code=res['code'], message=res['message'], data=res['data'])
